define([
    "jquery",
    // "comment"
    "signin"
], function ($, signin) {

    //导购区域推荐商品数据加载
    function recommendDownload() {
        let baseUrl = signin.getBaseUrl();
        $.get(baseUrl + "/system/recommend",
            function (res) {
                // console.log(res);
                let comArr = res.data; //对象格式
                // console.log(comArr);
                for (let arr in comArr) {
                    // console.log(arr);
                    for (let i = 0; i < comArr[arr].length; i++) {
                        // console.log(comArr[arr][i]);
                        let node = $(`                           
                        	<li>
                        		<dl>
                        			<dt><a href="goods.html?goodsId=${comArr[arr][i].id}"><img src="${comArr[arr][i].goodsImg}" alt="" /></a></dt>
                        			<dd><a href="goods.html?goodsId=${comArr[arr][i].id}">${comArr[arr][i].goodsName}</a></dd>
                        			<dd><span>售价：</span><strong> ￥${comArr[arr][i].shopPrice}</strong></dd>
                        		</dl>
                        	</li>
                            `);
                        if (arr == "crazy") {
                            node.appendTo(".guide_wrap .crazy ul");
                        }
                        if (arr == "hot") {
                            node.appendTo(".guide_wrap .hot ul");
                        }
                        if (arr == "new") {
                            node.appendTo(".guide_wrap .new ul");
                        }
                        if (arr == "rec") {
                            node.appendTo(".guide_wrap .rec ul");
                        }
                        if (arr == "guess") {
                            node.appendTo(".guide_wrap .guess ul");
                        }
                        node = '';
                    }
                }
            });
    }

    // 导购区域
    function guideTab() {
        $(".guide .guide_content ").on("mouseenter", "h2 span", function () {
            $(this).addClass("on").siblings().removeClass("on");
            let index = $(this).index();
            $(".guide_wrap div").each(function () {
                let $this = $(this);
                if ($this.index() == index) {
                    if ($this.hasClass("none")) {
                        $this.removeClass("none").siblings().addClass("none");
                    }
                }
            });

        });
    }

    // 商品列表鼠标移入移出事件
    function goodsListTab() {
        $(".floor_left .goodslist").on("mouseenter", "h2 span", function () {
            let index = $(this).index();
            $(this).addClass("on").siblings().removeClass("on");
            $(".goodslist_wrap div").each(function () {
                let $this = $(this);
                if ($this.index() == index) {
                    if ($this.hasClass("none")) {
                        $this.removeClass("none").siblings().addClass("none");
                    }
                }
            });
        });
    }


    return {
        guideTab: guideTab,
        goodsListTab: goodsListTab,
        recommendDownload: recommendDownload
    };

});